package com.my.feign;

import com.atguigu.springcloud.entities.Payment;
import com.baomidou.mybatisplus.extension.api.R;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class TestFeignFallBackFactory implements FallbackFactory<ITestFeignBackFactory> {

    @Override
    public ITestFeignBackFactory create(Throwable throwable) {
        log.error("请求出错:" + throwable.getMessage());
        return new ITestFeignBackFactory() {
            @Override
            public R<Payment> findOne(Long id) {
                return R.failed("获取失败fa");
            }
            @Override
            public R timeOut() {
                return R.failed("超时fa");
            }
        };
    }
}
